package com.shizhanzhe.zxbapp.vip;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;

import com.gyf.barlibrary.ImmersionBar;
import com.shizhanzhe.zxbapp.R;
import com.shizhanzhe.zxbapp.customtask.ScreenshotFragment;
import com.shizhanzhe.zxbapp.task.TabAdapter;
import com.shizhanzhe.zxbapp.task.TabFollowFragment;
import com.shizhanzhe.zxbapp.task.TabShareFragment;
import com.shizhanzhe.zxbapp.task.TabTaskFragment;
import com.shizhanzhe.zxbapp.task.newshare.ForwardFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zz9527 on 2018/11/6.
 */
public class VipMoreActivity extends FragmentActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_task);
        ImmersionBar.with(this).statusBarColor(R.color.them)
                .fitsSystemWindows(true)
                .init();
        ViewPager viewpager = findViewById(R.id.viewpager);
        TabLayout tab = findViewById(R.id.tab);
        List<String> tabTitle = new ArrayList<>();
        tabTitle.add("应用赚");
        tabTitle.add("分享赚");
        tabTitle.add("关注赚");
        tabTitle.add("更多赚");
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new TabTaskFragment());
        fragments.add(new ForwardFragment());
        fragments.add(TabFollowFragment.newInstance(1));
        fragments.add(new ScreenshotFragment());
        TabAdapter adapter = new TabAdapter(getSupportFragmentManager(), fragments, tabTitle);
        //给ViewPager设置适配器
        viewpager.setAdapter(adapter);
        //将TabLayout和ViewPager关联起来。
        tab.setupWithViewPager(viewpager);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        ImmersionBar.with(this).destroy(); //必须调用该方法，防止内存泄漏
    }
}